#ifndef SEQIOT_ALIOT_SERVICE_H
#define SEQIOT_ALIOT_SERVICE_H

#include <stdint.h>
#include <pthread.h>
#include "aiot_sysdep_api.h"
#include "model.h"

typedef struct _aliot_service_args_t {
    void *mqtt_handle;
    aiot_sysdep_network_cred_t *cred;
    seqiot_t *seqiot;
    void *userdata;
} aliot_service_args_t;

typedef struct _aliot_service_state_t {
    pthread_t pthread;
    void *exit_code;
} aliot_service_state_t;

typedef struct _aliot_service_t {
    char *name;
    void *handle;
    aliot_service_args_t *args;

    void *(*init)(aliot_service_args_t *args);

    void (*fini)(void **handle);

    void *(*start)(void *handle);

    int32_t (*stop)(void *handle);

    aliot_service_state_t _state;
} aliot_service_t;

int aliot_mqtt_start(aliot_service_t *service);

int aliot_service_start(aliot_service_t *service);

int aliot_service_stop(aliot_service_t *service);

aliot_service_t *mqtt_service_get();

aliot_service_t *dm_service_get();

aliot_service_t *subdev_service_get();

aliot_service_t *devinfo_service_get();

aliot_service_t *logpost_service_get();

aliot_service_t *ntp_service_get();

aliot_service_t *ra_service_get();

aliot_service_t *ota_service_get();

aliot_service_t *upload_service_get();

aliot_service_t *download_service_get();

aliot_service_t *pub_service_get();

aliot_service_t *hispub_service_get();

#endif //SEQIOT_ALIOT_SERVICE_H
